﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace LNUGame.View.ParticleSystemBloodSplatter
{
    /// <summary>
    /// Represents a single blood splatter/drop
    /// </summary>
    class BloodSplatterParticle
    {
        private Vector2 m_position;
        private Vector2 m_velocity;
        private readonly float m_maxLife;
        private float m_remainingLife;


        /// <summary>
        /// Main constructor.
        /// Sets the initial position to x = 0, y = 0 to make an expanding cloud
        /// </summary>
        /// <param name="a_velocity">The initial velocity</param>
        /// <param name="a_maxLife">The total lifetime</param>
        public BloodSplatterParticle(Vector2 a_velocity, float a_maxLife)
        {
            m_position = new Vector2(0, 0);
            m_velocity = a_velocity;
            m_maxLife = a_maxLife;
            m_remainingLife = a_maxLife;
        }


        /// <summary>
        /// Updates the position of the splatter particle.
        /// Decreases the remaining lifetime of the splatter particle.
        /// </summary>
        /// <param name="a_elapsedTime"></param>
        internal void Update(float a_elapsedTime)
        {
            m_remainingLife -= 0.1f;

            m_position += m_velocity * a_elapsedTime;
        }


        /// <summary>
        /// Getter for opacity
        /// </summary>
        internal float Opacity
        {
            get
            {
                return m_remainingLife / m_maxLife;
            }
        }

        /// <summary>
        /// Getter for position
        /// </summary>
        public Vector2 Position
        {
            get
            {
                return m_position;
            }
        }
    }
}
